<script setup lang="ts">
import { ref } from 'vue';


 const todoName = ref('')
 const emit= defineEmits(['addTodo'])
 const add = ()=> {
   if(todoName.value) {
    emit('addTodo', todoName.value);
    todoName.value = ''
   }
 }
</script>

<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="What needs to be done?"
      autofocus
      v-model="todoName"
      @keydown.enter="add"
    />
  </header>
</template>



<style lang="scss" scoped>

</style>